<template>
  <div :class="{ 'home-swipers': true, 'home-swipers-standard': layout == 'standard' }">
    <div class="swiper-vertical">
      <div class="title-text">消息中心</div>
      <ui-carousel direction="vertical" height="36px">
        <ui-carousel-item v-for="(item, index) in noticeList" :key="index">
          <div class="notice-img">
            <img src="@/assets/image/home/notice.png" />
            <p>{{ item.title }}</p>
          </div>
          <div class="swipers-text" v-if="item.type == 1">
            <p class="swipers-text-main">{{ item.item }}</p>
            <p class="swipers-text-time">{{ item.time }}</p>
          </div>
          <div class="swipers-text" v-if="item.type == 0">
            <p class="swipers-text-main">
              您有{{ item.item }}条通知
              <span class="swipers-text-main-span">查看详情</span>
            </p>
            <p class="swipers-text-time">{{ item.time }}</p>
          </div>
        </ui-carousel-item>
      </ui-carousel>
      <ui-button class="only-btn">
        <img class="img-logo" :src="require(`@/assets/image/theme/${activeName}/more.png`)" alt="" key="standard" v-if="layout == 'standard'" />
        <img class="img-logo" src="@/assets/image/home/arrow.png" alt="" v-else key="layout" />
      </ui-button>
    </div>
    <div class="line"></div>
  </div>
</template>

<script>
import systemApi from '@/api/system';
import { mapState } from 'vuex';
export default {
  data() {
    return {
      noticeList: [],
      isPageLoad: false, // 遮罩
    };
  },
  computed: {
    ...mapState('vxadmin/layout', ['layout']),
    ...mapState('vxadmin/theme', ['activeName']),
  },
  created() {
    this.getNoticeList();
  },
  methods: {
    // 得到通知信息
    async getNoticeList() {
      try {
        // 开启遮罩
        this.isPageLoad = true;
        const res = await systemApi.getNotice();
        this.noticeList = res.noticeList;
      } catch (error) {
        this.$message.error(error.message);
      } finally {
        // 关闭遮罩
        this.isPageLoad = false;
      }
    },
  },
};
</script>

<style lang="scss">
.home-swipers {
  margin-top: 10px;
  .swiper-vertical {
    display: flex;
    flex-direction: row;
    height: 36px;
    background: $color-bg-default;
    border-radius: 8px;
    box-shadow: 0px 1px 10px 0px rgba(0, 21, 41, 0.07);
    .title-text {
      height: 22px;
      width: 70px;
      font-size: $s16;
      text-align: left;
      color: $color-text-main;
      line-height: 21px;
      letter-spacing: 0px;
      margin: auto 10px;
      font-weight: 600;
      min-width: 65px;
    }
    .ui-carousel--vertical {
      width: 80%;
    }
    .notice-img {
      text-align: center;
      font-size: $s14;
      color: $color-text-primary;
      margin-left: 10px;
      position: absolute;
      top: 7px;
      img {
        height: 22px;
        width: 70px;
      }
      p {
        position: absolute;
        top: 1px;
        left: 4px;
      }
    }
    .swipers-text {
      line-height: 36px;
      font-size: $s14;
      display: flex;
      flex-direction: row;
      margin-left: 90px;
      .swipers-text-main {
        width: 70%;
        .swipers-text-main-span {
          color: #02a7f0;
          cursor: pointer;
        }
      }
      .swipers-text-time {
        color: $color-text-sub;
        margin: 0 10px;
      }
    }
  }
  .line {
    height: 10px;
    width: 100%;
  }
  .swiper-horizontal {
    height: 264px;
    padding: 20px;
    box-sizing: border-box;
    background: $color-bg-default;
    img {
      width: 100%;
      height: 224px;
    }
  }
  .ui-carousel__container {
    height: 100%;
  }
  .only-btn {
    border: none;
    padding: 5px;
  }
}
.home-swipers-standard {
  margin-top: 0px;
  .swiper-vertical {
    background: rgba(225, 225, 225, 0.15);
    .title-text {
      color: $color-text-primary;
    }
    .swipers-text {
      .swipers-text-main {
        color: $color-text-primary;
      }
      .swipers-text-time {
        color: $color-text-primary;
      }
    }
    .only-btn {
      background: rgba(225, 225, 225, 0);
    }
  }
  .ui-carousel__indicators--vertical {
    opacity: 0;
  }
}
</style>
